package com.dt76.smallloanbackendservice.controller.ysy;

import com.dt76.smallloanbackendservice.pojo.ysy.ApprovalLoan;
import com.dt76.smallloanbackendservice.service.ysy.AppService;
import com.dt76.smallloanbackendservice.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/ysy")
public class AppController {
    @Autowired
    private AppService appService2;

    @RequestMapping("/account2")
    @ResponseBody
    public List<ApprovalLoan> qryAppAll2(){
        return appService2.qryAppAll2();
    }

    @RequestMapping("/delapp")
    @ResponseBody
    public Result delapp(@RequestParam("alId") int alId){
        System.out.println("成功调用远程服务:userservice>delete>>>");
        try {
            appService2.delapp(alId);
            return new Result(true,"删除成功>>>");
        } catch (Exception e) {
            return new Result(false,"删除失败>>>");
        }
    }
    @RequestMapping("/addapp")
    public Result addapp(@RequestBody ApprovalLoan approvalLoan){
        System.out.println("成功调用远程服务:userservice>add>>>");
        //调用新增接口
        appService2.addapp(approvalLoan);
        try {
            appService2.addapp(approvalLoan);
            return new Result(true,"新增成功>>>");
        } catch (Exception e) {
            return new Result(false,"新增异常");
        }
    }

}
